# data/feature_generator.py

import pandas as pd

class FeatureGenerator:
    def __init__(self, df: pd.DataFrame):
        self.df = df.copy()

    def generate(self):
        df = self.df

        # ✅ 1. 成交额结构
        df["price_deal_ratio"] = df["price"] * df["deal_money"]

        # ✅ 2. 波动性
        if "high" in df.columns and "low" in df.columns:
            df["volatility"] = (df["high"] - df["low"]).abs()

        # ✅ 3. 距离60日高点
        df["price_max_gap"] = df["calculate_max_price"]

        # ✅ 4. 个股-日期聚合字段（仅当字段缺失时占位）
        for col in ["sum_money_gt_300w", "money_count_ge_300w", "money_count_ge_500w"]:
            if col not in df.columns:
                df[col] = None


        return df
